<!DOCTYPE html>
<html>
	{include file="public/header" /}
	<style type="text/css">
		.diyinput {
			height: 38px;
			line-height: 1.3;
			line-height: 38px;
			border-width: 1px;
			border-style: solid;
			background-color: #fff;
			border-radius: 2px;
			border-color: #f1eeee;
		}
	</style>
	<link href="/dist/css/zoomify.min.css" rel="stylesheet">

	<body>
		<div class="layui-tab">
			<ul class="layui-tab-title">
				<li class="layui-this">正常</li>
				<li class="songsong">逾期</li>
			</ul>
			<div class="layui-tab-content">
				<!--正常-->
				<div class="layui-tab-item layui-show aaaa">
					<div class="layui-fluid">
						<div class="layui-card">
							<div class="layui-form layui-card-header layuiadmin-card-header-auto">
								<div class="layui-form-item">
									{include file="public/sorch" /} {include file="public/qudao" /} {include file="public/yyfkTime" /}
									<div class="layui-inline">
										<button class="layui-btn layuiadmin-btn-useradmin_zhengchang" lay-submit lay-filter="LAY-user-front-search_zhengchang">
                                               <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                      </button>
									</div>
								</div>
							</div>
							<div class="layui-card-body">
								<table id="LAY-user-manage_huankuan_zhengchang" lay-filter="LAY-user-manage_zhengchang"></table>
								<script type="text/html" id="table-useradmin-webuser_zhengchang">
									<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="detail"><i class="layui-icon "></i>详情</a>
									<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="huankuan"><i class="layui-icon "></i>还款</a>
									<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="zhanqi"><i class="layui-icon "></i>展期</a>
									<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="huomian"><i class="layui-icon"></i>豁免</a>

								</script>
							</div>
						</div>
					</div>
				</div>
				<!--逾期-->
				<div class="layui-tab-item ">
					<div class="layui-fluid">
						<div class="layui-card">
							<div class="layui-form layui-card-header layuiadmin-card-header-auto">
								<div class="layui-form-item">
									{include file="public/sorch" /} {include file="public/qudao" /} {include file="public/yyfkTime" /}

									<div class="layui-inline">
										<button class="layui-btn layuiadmin-btn-useradmin_yuqi" lay-submit lay-filter="LAY-user-front-search_yuqi">
                                               <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                    </button>
									</div>
								</div>
							</div>
							<div class="layui-card-body">
								<table id="LAY-user-manage_huankuan_yuqi" lay-filter="LAY-user-manage_yuqi"></table>
								<script type="text/html" id="table-useradmin-webuser_yuqi">
									<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="detail"><i class="layui-icon "></i>详情</a>
									<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="huankuan"><i class="layui-icon"></i>还款</a>
									<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="zhanqi"><i class="layui-icon "></i>展期</a>
									<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="huomian"><i class="layui-icon"></i>豁免</a>
								</script>

							</div>
						</div>
					</div>
				</div>
				{include file="public/footer" /}

				<script>
					layui.use(['index', 'table', 'laydate', 'element'], function() {
						var $ = layui.$,
							form = layui.form,
							table = layui.table,
							laydate = layui.laydate;
						//						正常
						table.render({
							elem: '#LAY-user-manage_huankuan_zhengchang',
							even: true, //开启隔行背景
							url: "{:url('admin/orderhuankuan/get_list')}?songsong=huankuan_zhengchang",
							title: '正常',
							height: 'full-300', //最大高度
							cols: [
								[{
										type: 'checkbox',
										fixed: 'left'
									},
									{
										type: 'numbers',
										title: '排序',
										width: 40,
										fixed: 'left',
										unresize: true,
									},
									{
										field: 'TrueName',
										title: '姓名',
										width: 80,
									},
									{
										field: 'Mobile',
										title: '手机号',
										width: 120,

									},
									{
										field: 'TgadminID',
										title: '渠道',
										width: 80,

									},
									
									{
										field: 'YyFkTime',
										title: '应还时间',
										width: 110,
									},

									{
										field: 'jishen',
										title: "<span lay-tips='滴滴风控显示分数  磨盘风控显示结果'><p style='text-align:center'>机审结果</p></span>",
										width: 150,

									},
									{
										field: 'ApplyMoney',
										title: '订单金额',
										width: 100,
									},
									{
										field: 'ApplyDay',
										title: '期限',
										width: 60,
									},
									{
										field: 'AdoptMoney',
										title: '到账金额',
										width: 100,
									},

									{
										field: 'jianmian_money',
										title: '应还减免',
										width: 100,
									},
									{
										field: 'bufen_money',
										title: '部分已还',
										width: 100,
									},
									//									{
									//										field: 'daoqiMoney',
									//										title: "<span lay-tips='到账金额+服务费  '><p style='text-align:center'>到期应还</p></span>",
									//										width: 100,
									//									},
									{
										field: 'dingdan_yinghuan_money',
										title: "<span lay-tips='到账金额+服务费+逾期费'><p style='text-align:center'>订单应还</p></span>",
										width: 100,
									},
									{
										field: 'muqian_yinghuan_money',
										title: "<span lay-tips='订单应还-部分还款-豁免'><p style='text-align:center'>目前应还</p></span>",
										width: 100,
									},
									{
										field: 'Jktime',
										title: '(总)借款次数',
										width: 120
									},
									{
										field: 'user_type',
										title: '客户类型',
										width: 100,
									},
									{
										field: 'xjnums_status',
										title: '是否展期',
										width: 100,
									},

									{
										field: 'xjnums',
										title: '展期次数',
										width: 100,
									},

									{
										field: 'ApplyTime',
										title: '申请时间',
										width: 160,
									},
									{
										field: 'ShTime',
										title: '审核时间',
										width: 160,
									},

									{
										field: 'ShadminID',
										title: '审核客服',
										width: 100,
									},

									{
										field: 'OpenTime',
										title: '放款时间',
										width: 160,
									},
									{
										field: 'pay',
										title: '放款方式',
										width: 100,
									},
									{
										field: 'FkadminID',
										title: '放款客服',
										width: 100,
									},
									{
										field: 'app_type',
										title: "<span lay-tips='首借、复借、正常展期、逾期展期'><p style='text-align:center'>订单类型</p></span>",
										width: 100,
									},
									
									{
										field: 'IDCard',
										title: '身份证号',
										width: 175,

									},
									{
										field: 'OrderSn',
										title: '订单编号',
										width: 180,
									},

									{
										fixed: 'right',
										title: '操作',
										toolbar: '#table-useradmin-webuser_zhengchang',
										width: 220
									}
								]

							],
							page: true
						});
						//监听工具条
						table.on('tool(LAY-user-manage_zhengchang)', function(obj) {
							var data = obj.data;
							if(obj.event === 'detail') {
								layer.open({
									type: 2,
									title: '用户详情',
									content: 'detail.html?ID=' + data.ID,
									area: ['80%', '70%'],
									btn: ['确定', '取消'],

								});

							} else if(obj.event === 'zhanqi') {
								layer.open({
									type: 2,
									title: '展期用户',
									content: 'zhanqi.html?ID=' + data.ID,
									area: ['50%', '60%'],
									btn: ['确定', '取消'],
									yes: function(index, layero) {
										var iframeWindow = window['layui-layer-iframe' + index],
											submitID = 'LAY-user-back-submit',
											submit = layero.find('iframe').contents().find('#' + submitID);

										//监听提交
										iframeWindow.layui.form.on('submit(' + submitID + ')', function(data) {
											var field = data.field; //获取提交的字段

											//								
											//提交 Ajax 成功后，静态更新表格中的数据
											$.ajax({
												'type': 'post',
												'url': "{:url('admin/orderhuankuan/zhanqi_caozuo')}",
												'data': field,
												dataType: 'json',
												success: function(res) {
													if(res.code == '0') {
														layer.msg(res.msg, {
															icon: 1
														});
													} else {
														layer.msg(res.msg, {
															icon: 5
														});
													}
													table.reload('LAY-user-manage_huankuan_zhengchang');
													layer.close(index); //关闭弹层
												}
											});

										});

										submit.trigger('click');
									}
								});
							} else if(obj.event === 'huankuan') {
								layer.open({
									type: 2,
									title: '线下还款',
									content: 'huankuan.html?ID=' + data.ID,
									area: ['50%', '70%'],
									btn: ['确定', '取消'],
									yes: function(index, layero) {

										var iframeWindow = window['layui-layer-iframe' + index],
											submitID = 'LAY-user-back-submit',
											submit = layero.find('iframe').contents().find('#' + submitID);
										//监听提交
										iframeWindow.layui.form.on('submit(' + submitID + ')', function(data) {
											var field = data.field; //获取提交的字段
											//											console.log(field.moneysheng);
											//											console.log(field.Type);

											if(field.Type == 2 && field.moneysheng != 0) {
												alert('剩余应还金额为0才能执行结清操作');
											} else if(field.Type == 1 && field.moneysheng == 0) {
												alert('剩余应还金额为0请选择结清操作');

											} else {
												//提交 Ajax 成功后，静态更新表格中的数据
												$.ajax({
													'type': 'post',
													'url': "{:url('admin/orderhuankuan/huankuan_caozuo')}",
													'data': field,
													dataType: 'json',
													success: function(res) {
														if(res.code == '0') {
															layer.msg(res.msg, {
																icon: 1
															});
														} else {
															layer.msg(res.msg, {
																icon: 5
															});
														}
														table.reload('LAY-user-manage_huankuan_zhengchang');
														layer.close(index); //关闭弹层
													}
												});

											}

										});

										submit.trigger('click');
									}
								});
							} else if(obj.event === 'huomian') {
								layer.open({
									type: 2,
									title: '豁免',
									content: 'huomian.html?ID=' + data.ID,
									area: ['80%', '70%'],
									btn: ['确定', '取消'],
									yes: function(index, layero) {
										var iframeWindow = window['layui-layer-iframe' + index],
											submitID = 'LAY-user-back-submit',
											submit = layero.find('iframe').contents().find('#' + submitID);
										//监听提交
										iframeWindow.layui.form.on('submit(' + submitID + ')', function(data) {
											var field = data.field; //获取提交的字段
											//								
											//提交 Ajax 成功后，静态更新表格中的数据
											$.ajax({
												'type': 'post',
												'url': "{:url('admin/orderhuankuan/huankuan_caozuo')}",
												'data': field,
												dataType: 'json',
												success: function(res) {
													if(res.code == '0') {
														layer.msg(res.msg, {
															icon: 1
														});
													} else {
														layer.msg(res.msg, {
															icon: 5
														});
													}
													table.reload('LAY-user-manage_huankuan_zhengchang');
													layer.close(index); //关闭弹层
												}
											});

										});

										submit.trigger('click');
									}
								});
							}
						});
						//监听搜索   正常
						form.on('submit(LAY-user-front-search_zhengchang)', function(data) {
							var field = data.field;

							//执行重载
							table.reload('LAY-user-manage_huankuan_zhengchang', {
								where: field
							});
						});

						//	逾期
						table.render({
							elem: '#LAY-user-manage_huankuan_yuqi',
							even: true, //开启隔行背景
							url: "{:url('admin/orderhuankuan/get_list')}?songsong=huankuan_yuqi",
							title: '逾期',
							cols: [
								[{
										type: 'checkbox',
										width: 40,
										fixed: 'left'
									},
									{
										type: 'numbers',
										title: '排序',
										width: 40,
										fixed: 'left',
										unresize: true,
									},
									{
										field: 'TrueName',
										title: '姓名',
										width: 80,
									},
									{
										field: 'Mobile',
										title: '手机号',
										width: 120,

									},
									{
										field: 'DaichaoName',
										title: '渠道',
										width: 80,

									},

									{
										field: 'YyFkTime',
										title: '应还还款时间',
										width: 160,
									},
									
									
									{
										field: 'IDCard',
										title: '身份证号',
										width: 175,

									},
									{
										field: 'jishen',
										title: "<span lay-tips='滴滴风控显示分数  磨盘风控显示结果'><p style='text-align:center'>机审结果</p></span>",
										width: 100,

									},
									{
										field: 'ApplyMoney',
										title: '订单金额',
										width: 100,
									},
									{
										field: 'ApplyDay',
										title: '期限',
										width: 60,
									},
									{
										field: 'AdoptMoney',
										title: '到账金额',
										width: 100,
									},

									{
										field: 'jianmian_money',
										title: '应还减免',
										width: 100,
									},
									{
										field: 'datas',
										title: '逾期天数',
										width: 100,
									},

									{
										field: 'fakuan',
										title: '逾期金额',
										width: 100,
									},

									{
										field: 'bufen_money',
										title: '部分已还',
										width: 100,
									},
									{
										field: 'dingdan_yinghuan_money',
										title: "<span lay-tips='到账金额+服务费+逾期费'><p style='text-align:center'>订单应还</p></span>",
										width: 100,
									},
									{
										field: 'muqian_yinghuan_money',
										title: "<span lay-tips='订单应还-部分还款-豁免'><p style='text-align:center'>目前应还</p></span>",
										width: 100,
									},
									{
										field: 'Jktime',
										title: '(总)借款次数',
										width: 120
									},
									{
										field: 'user_type',
										title: '客户类型',
										width: 100,
									},
									{
										field: 'xjnums_status',
										title: '是否展期',
										width: 100,
									},

									{
										field: 'xjnums',
										title: '展期次数',
										width: 100,
									},

									{
										field: 'ApplyTime',
										title: '申请时间',
										width: 160,
									},
									{
										field: 'ShTime',
										title: '审核时间',
										width: 160,
									},
									{
										field: 'ApplyMoney',
										title: '到期应还',
										width: 100,
									},

									{
										field: 'ShadminID',
										title: '审核客服',
										width: 100,
									},

									{
										field: 'OpenTime',
										title: '放款时间',
										width: 160,
									},
									{
										field: 'pay',
										title: '放款方式',
										width: 160,
									},
									{
										field: 'FkadminID',
										title: '放款客服',
										width: 160,
									},
									{
										field: 'OrderSn',
										title: '订单编号',
										width: 180,
									},
									{
										fixed: 'right',
										title: '操作',
										toolbar: '#table-useradmin-webuser_yuqi',
										width: 220
									}
								]

							],
							page: true
						});

						//监听工具条
						table.on('tool(LAY-user-manage_yuqi)', function(obj) {
							var data = obj.data;
							if(obj.event === 'detail') {
								layer.open({
									type: 2,
									title: '用户详情',
									content: 'detail.html?ID=' + data.ID,
									area: ['90%', '90%'],
									btn: ['确定', '取消'],

								});

							} else if(obj.event === 'zhanqi') {
								layer.open({
									type: 2,
									title: '展期用户',
									content: 'zhanqi.html?ID=' + data.ID,
									area: ['50%', '80%'],
									btn: ['确定', '取消'],
									yes: function(index, layero) {
										var iframeWindow = window['layui-layer-iframe' + index],
											submitID = 'LAY-user-back-submit',
											submit = layero.find('iframe').contents().find('#' + submitID);
										//监听提交
										iframeWindow.layui.form.on('submit(' + submitID + ')', function(data) {
											var field = data.field; //获取提交的字段
											//								
											//提交 Ajax 成功后，静态更新表格中的数据
											$.ajax({
												'type': 'post',
												'url': "{:url('admin/orderhuankuan/zhanqi_caozuo')}",
												'data': field,
												dataType: 'json',
												success: function(res) {
													if(res.code == '0') {
														layer.msg(res.msg, {
															icon: 1
														});
													} else {
														layer.msg(res.msg, {
															icon: 5
														});
													}
													table.reload('LAY-user-manage_huankuan_yuqi');
													layer.close(index); //关闭弹层
												}
											});

										});

										submit.trigger('click');
									}
								});
							} else if(obj.event === 'huankuan') {
								layer.open({
									type: 2,
									title: '线下还款',
									content: 'huankuan.html?ID=' + data.ID,
									area: ['50%', '80%'],
									btn: ['确定', '取消'],
									yes: function(index, layero) {
										var iframeWindow = window['layui-layer-iframe' + index],
											submitID = 'LAY-user-back-submit',
											submit = layero.find('iframe').contents().find('#' + submitID);
										//监听提交
										iframeWindow.layui.form.on('submit(' + submitID + ')', function(data) {
											var field = data.field; //获取提交的字段
											//								
											//提交 Ajax 成功后，静态更新表格中的数据
											$.ajax({
												'type': 'post',
												'url': "{:url('admin/orderhuankuan/huankuan_caozuo')}",
												'data': field,
												dataType: 'json',
												success: function(res) {
													if(res.code == '0') {
														layer.msg(res.msg, {
															icon: 1
														});
													} else {
														layer.msg(res.msg, {
															icon: 5
														});
													}
													table.reload('LAY-user-manage_huankuan_yuqi');
													layer.close(index); //关闭弹层
												}
											});

										});

										submit.trigger('click');
									}
								});
							} else if(obj.event === 'huomian') {
								layer.open({
									type: 2,
									title: '豁免',
									content: 'huomian.html?ID=' + data.ID,
									area: ['50%', '80%'],
									btn: ['确定', '取消'],
									yes: function(index, layero) {
										var iframeWindow = window['layui-layer-iframe' + index],
											submitID = 'LAY-user-back-submit',
											submit = layero.find('iframe').contents().find('#' + submitID);
										//监听提交
										iframeWindow.layui.form.on('submit(' + submitID + ')', function(data) {
											var field = data.field; //获取提交的字段
											//								
											//提交 Ajax 成功后，静态更新表格中的数据
											$.ajax({
												'type': 'post',
												'url': "{:url('admin/orderhuankuan/huankuan_caozuo')}",
												'data': field,
												dataType: 'json',
												success: function(res) {
													if(res.code == '0') {
														layer.msg(res.msg, {
															icon: 1
														});
													} else {
														layer.msg(res.msg, {
															icon: 5
														});
													}
													table.reload('LAY-user-manage_huankuan_yuqi');
													layer.close(index); //关闭弹层
												}
											});

										});

										submit.trigger('click');
									}
								});
							}
						});
						//监听搜索   还款  单
						form.on('submit(LAY-user-front-search_yuqi)', function(data) {
							var field = data.field;

							//执行重载
							table.reload('LAY-user-manage_huankuan_yuqi', {
								where: field
							});
						});
						//						点击事件
						$('.layui-btn.layuiadmin-btn-useradmin_zhengchang.layuiadmin-btn-useradmin_yuqi').on('click', function() {
							var type = $(this).data('type');
							active[type] ? active[type].call(this) : '';
						});

						//						点击逾期tab切换执行重载 逾期里面的数据
						$('.songsong').on('click', function() {
							//							alert(12);
							//执行重载
							table.reload('LAY-user-manage_huankuan_yuqi', {
								//								where: field
							});
						});

						var laydate = layui.laydate;
						//日期范围
						laydate.render({
							elem: '#test6',
							range: true
						});
					});
				</script>
	</body>

</html>